import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [
  // 前台路由
  {
    name: "Blog",
    path: "/",
    component: () => import("@/components/blog/Layout"),
    redirect: "/index",
    children: [
      {
        name: "BlogCategory",
        path: "/category",
        component: () => import("@/views/Blog/Category")
      },
      {
        name: "BlogLink",
        path: "/link",
        component: () => import("@/views/Blog/Link")
      },
      {
        name: "PostDetail",
        path: "/post/detail",
        component: () => import("@/views/Blog/Post/PostDetail")
      },
      {
        name: "BlogIndex",
        path: "/index",
        component: () => import("@/views/Blog/Post/PostList")
      }
    ]
  },
  // 后台路由
  {
    name: "Admin",
    path: "/admin",
    component: () => import("@/components/admin/Layout"),
    children: [
      {
        name: "DashBoard",
        path: "/admin",
        component: () => import("@/views/Admin/Index"),
        meta: {
          name: "仪表盘",
          icon: "ios-color-palette"
        }
      },
      {
        name: "Category",
        path: "/admin/category",
        component: () => import("@/views/Admin/Category"),
        meta: {
          name: "分类",
          icon: "ios-navigate"
        }
      },
      {
        name: "Link",
        path: "/admin/link",
        component: () => import("@/views/Admin/Link"),
        meta: {
          name: "友情链接",
          icon: "ios-link"
        }
      },
      {
        name: "Config",
        path: "/admin/config",
        component: () => import("@/views/Admin/Config"),
        meta: {
          name: "系统配置",
          icon: "ios-settings"
        }
      },
      {
        name: "Tag",
        path: "/admin/tag",
        component: () => import("@/views/Admin/Tag"),
        meta: {
          name: "Tag",
          icon: "ios-link"
        }
      },
      {
        name: "PostAddAndEdit",
        path: "/admin/post/modify",
        component: () => import("@/views/Admin/Post/PostAddAndEdit"),
        meta: {
          name: "文章添加",
          icon: "logo-tux"
        }
      },
      {
        name: "PostList",
        path: "/admin/post/list",
        component: () => import("@/views/Admin/Post"),
        meta: {
          name: "文章列表",
          icon: "md-git-branch"
        }
      }
    ]
  },
  {
    path: "/404",
    name: "NotFound",
    component: () => import("@/components/NotFound")
  },
  {
    path: "*", // 此处需特别注意置于最底部
    redirect: "/404"
  }
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes
});

export default router;
